import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class jdbcdemo5_ResultSet {

    public void testResultSet() throws Exception {
        Class.forName("com.mysql.jdbc.Driver");
        /*本机MySQL并且端口3306可以简化书写
        String url = "jdbc:mysql://cc";
         */
        String url = "jdbc:mysql://192.168.2.131:3306/cc";
        String username = "root";
        String password = "abc123";
        Connection conn = DriverManager.getConnection(url,username,password);

        String sql = "select * from account";

        Statement stmt = conn.createStatement();

        ResultSet rs =stmt.executeQuery(sql);

        while (rs.next()){

            int id = rs.getInt(1);
            String name = rs.getString(2);
            double money = rs.getDouble(3);


            System.out.println(id);
            System.out.println(name);
            System.out.println(money);


            System.out.println("------------------------------");

        }



        rs.close();
        stmt.close();
        conn.close();
    }







}

